#!/usr/bin/env python

##########################################################################
# File Name: models.py
# Author: baohua
# Mail: liubaohuachina@163.com
# Create Time: 2020/03/24 08:49:37
# Version: 1.0
# Description:
##########################################################################

from sqlalchemy import (
    Column,
    Integer,
    String,
    DateTime)
from sqlalchemy.dialects.mysql import JSON
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()


class CommonAttrMixin(object):
    """公共基本字段，所有表共享
    enable: 0-不可用 1-可用
    """
    id = Column(Integer, primary_key=True, autoincrement=True)
    is_delete = Column(Integer, nullable=False, server_default='0')
    enable = Column(Integer, nullable=False, server_default='1')
    create_id = Column(String(32))
    create_time = Column(DateTime)
    update_id = Column(String(32))
    update_time = Column(DateTime)
    delete_id = Column(String(32))
    delete_time = Column(DateTime)
    info = Column(JSON, nullable=False, server_default='{}')


class Person(Base):
    __tablename__ = 'person'

    id = Column(Integer, primary_key=True, autoincrement=True)
    firstname = Column(String(255), nullable=False)
    lastname = Column(String(255), nullable=False)
